package org.example.seckill.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.seckill.service.UserService;
import org.example.seckill.vo.LoginVo;
import org.example.seckill.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author woopsion
 * @date 2025-06-28
 * 返回 login 页面等操作，主要是后端的书写，login页面就不写了
 */
@Slf4j
@Controller
@RequestMapping("/login")
public class LoginController {

    @Autowired
    UserService userService;
    
    @RequestMapping("/toLogin")
    public String login(){
    
        //
        return "login";
    }
    
    @RequestMapping("/doLogin")
    @ResponseBody
    public RespBean doLogin(LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){
        log.info(loginVo.toString());
        return userService.login(loginVo,request,response);
    }
}
